﻿using System;
using System.Web.Mvc;
using GroceryList.Front.Web.Service;
using MvcContrib;

namespace GroceryList.Front.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IListaCompraService _listaCompraService;

        public HomeController(IListaCompraService listaCompraService)
        {
            _listaCompraService = listaCompraService;
        }

        public ActionResult Index()
        {
            var listas = _listaCompraService.ObtenerTodas();
            return View(listas);
        }

        [HttpGet]
        public ActionResult Delete(Guid codigoLista)
        {
            _listaCompraService.Eliminar(codigoLista);
            return this.RedirectToAction(c => c.Index());            
        }
    }
}
